1. Field
The described embodiments relate to techniques for performing a query of a database. More specifically, the described embodiments relate to techniques for translating an arbitrary query into an edge query for use with a graph database.
2. Related Art
Data associated with applications is often organized and stored in databases. For example, in a relational database data is organized based on a relational model into one or more tables of rows and columns, in which the rows represent instances of types of data entities and the columns represent associated values. Information can be extracted from a relational database using queries expressed in a Structured Query Language (SQL).
In principle, by linking or associating the rows in different tables, complicated relationships can be represented in a relational database. In practice, extracting such complicated relationships usually entails performing a set of queries and then determining the intersection of or joining the results. In general, by leveraging knowledge of the underlying relational model, the set of queries can be identified and then performed in an optimal manner.
However, applications often do not know the relational model in a relational database. Instead, from an application perspective, data is usually viewed as a hierarchy of objects in memory with associated pointers. Consequently, many applications generate queries in a piecemeal manner, which can make it difficult to identify or perform a set of queries on a relational database in an optimal manner. This can degrade performance and the user experience when using applications.
A variety of approaches have been used in an attempt to address this problem, including using an object-relational mapper, so that an application effectively has an understanding or knowledge about the relational model in a relational database. However, it is often difficult to generate and to maintain the object-relational mapper, especially for large, real-time applications.
Alternatively, a key-value store (such as a NoSQL database) may be used instead of a relational database. A key-value store may include a collection of objects or records and associated fields with values of the records. Data in a key-value store may be stored or retrieved using a key that uniquely identifies a record. By avoiding the use of a predefined relational model, a key-value store may allow applications to access data as objects in memory with associated pointers, i.e., in a manner consistent with the application's perspective. However, the absence of a relational model means that it can be difficult to optimize a key-value store. Consequently, it can also be difficult to extract complicated relationships from a key-value store (e.g., it may require multiple queries), which can also degrade performance and the user experience when using applications.
Table 1 provides an edge query in accordance with an embodiment of the present disclosure.
Table 2 provides data in JavaScript Object Notation (JSON) in accordance with an embodiment of the present disclosure.
Table 3 provides an edge query in accordance with an embodiment of the present disclosure.
Table 4 provides a result for an edge query in accordance with an embodiment of the present disclosure.
Table 5 provides a set of commands that defines a compound relationship in accordance with an embodiment of the present disclosure.
Table 6 provides a set of commands that defines a compound relationship in accordance with an embodiment of the present disclosure.
Note that like reference numerals refer to corresponding parts throughout the drawings. Moreover, multiple instances of the same part are designated by a common prefix separated from an instance number by a dash.